<?php

namespace app\model\zs;

use think\Model;

class ZsTwShopGoods extends Model
{
    // 设置当前模型对应的完整数据表名称
    protected $table = 'tw_shop_goods';

    // 设置当前模型的数据库连接
    protected $connection = 'zs';

    const TRUCK_FREE = 0;
    const TRUCK_FEE = 1001;

    const DELETED_OFF = 0;
    const DELETED_ON = 1;

    const STATUS_OFF = 0;
    const STATUS_ON = 1;

    public function shopGoodsCate()
    {
        return $this->hasOne(ZsTwShopGoodsCate::class, 'id', 'cate');
    }

    public function shopGoodsItems()
    {
        return $this->hasMany(ZsTwShopGoodsItem::class, 'goods_code', 'code');
    }

    public function businessModel()
    {
        return $this->belongsTo(ZsBusiness::class, 'bid', 'id');
    }

    public static function statusRels()
    {
        return [
            0 => '已下架',
            1 => '正常',
        ];
    }

    public static function statusClassRels()
    {
        return [
            0 => 'error',
            1 => '',
        ];
    }

    public static function truckRels()
    {
        return [
            self::TRUCK_FREE => '用户免配送费',
            self::TRUCK_FEE => '用户承担配送费',
        ];
    }
}
